<template>
    <div class="mask">
        <div class="TMB-warp">
            <div class="titler">
                <span class="font-w fs16" style="font-weight: 700;">肉厚測定点一覧</span>
                <i class="el-icon-close" @click="CloseTables"></i>
            </div>
            <div class="middle">
                <ux-grid class="ux-table" ref="singleTable" :data="prposTabelData" :header-cell-style="{
                    color: 'rgba(0, 0, 0, 0.85)',
                    fontSize: '14px',
                    textAlign: 'left',
                    fontWeight: 'bold',
                    padding: 0,
                    height: '32px',
                    background: 'rgb(244,245,246)'
                }" :cell-style="{
                    color: 'rgba(96,98,102,1)',
                    fontSize: '14px',
                    textAlign: 'left',
                    padding: 0,
                    height: '32px',
                }" :checkbox-config="{
                    showHeader: false,
                }" highlight-current-row @current-change="handleCurrentChange" v-loading="loading"
                    element-loading-spinner="el-icon-loading" element-loading-background="#f8f8f8"
                    :element-loading-text="$t('message.bhView.loading')" height="300">
                    <template slot="empty"> No data </template>
                    <ux-table-column property="label" title="定点No." width="92px">
                        <template slot-scope="scope">
                            <p style="text-align: right;">
                                {{ scope.row.posOrdr }}
                            </p>
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="定点名称" width="100px">
                        <template slot-scope="scope">
                            {{ scope.row.posName }}
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="測定部位" width="100px">
                        <template slot-scope="scope">
                            {{ scope.row.partName }}
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="材質名称" width="100px">
                        <template slot-scope="scope">
                            {{ scope.row.mtrName }}
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="サイズ" width="100px">
                        <template slot-scope="scope">
                            {{ scope.row.sizName }}
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="元肉厚" width="100px">
                        <template slot-scope="scope">
                            <p style="text-align: right;">
                                {{ scope.row.orgThck }}
                            </p>
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="管理値" width="100px">
                        <template slot-scope="scope">
                            <p style="text-align: right;">
                                {{ scope.row.mgtThck }}
                            </p>
                        </template>
                    </ux-table-column>
                    <ux-table-column property="label" title="建設年月" width="100px">
                        <template slot-scope="scope">
                            {{ scope.row.chgDate }}
                        </template>
                    </ux-table-column>
                </ux-grid>

                <div class="footer">
                    <div>
                        件数 = {{ prposTabelData.length }} 点
                    </div>
                    <el-button type="primary" size="mini" @click="saveFn">選択</el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import { GetCGOperationDetialsThickSpec } from '@/api/api'
export default {
    name: "RTable",
    props: {
    },
    data() {
        return {
            prposTabelData: [],

            loading: false,
            value: '',
            selectItem: {}

        };
    },
    components: {},
    watch: {},
    methods: {
        handleCurrentChange(val) {
            console.log(val);
            this.selectItem = val
        },
        CloseTables() {
            this.$emit('hidden')
        },
        async saveFn() {
            if (Object.keys(this.selectItem).length == 0) {
                return
            }
            this.$emit('getRTableDataFn', this.selectItem);
            this.$emit('hidden');
        },

        async initFn() {
            let dataJson = {
                DmgCode: this.$store.state.macCode,
            }
            let res = await GetCGOperationDetialsThickSpec(dataJson);
            this.loading = false;
            if (res.data.code != 0 && res.data.data.length != 0) {
                return
            }
            this.prposTabelData = res.data.data;
            this.$refs.singleTable.setCurrentRow(this.prposTabelData[0]);
            this.selectItem = this.prposTabelData[0];
        }
    },
    created() { },
    mounted() {
        this.initFn();
    },
    beforeDestroy() { },
    destroyed() { }
};
</script>
<style lang="scss" scoped>
.mask {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 500;
}

.TMB-warp {
    width: 850px;
    background: rgb(255, 255, 255);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translateX(-50%) translateY(-50%);
    box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.05),
        0px 9px 28px 0px rgba(0, 0, 0, 0.08), 0px 6px 16px -8px rgba(0, 0, 0, 0.15);
    z-index: 100;

    .titler {
        height: 43px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 13px 24px;
        border-bottom: 1px solid #F0F0F0FF;

        i {
            cursor: pointer;
        }
    }

    .middle {
        padding: 13px 24px;

        .title {
            display: flex;
            margin-bottom: 13px;

            .seach {
                width: 24px;
                height: 24px;
                border-radius: 4px;
                border: 1px solid #d9d9d9;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
                margin-right: 12px;
            }

            .form-ipt {
                height: 24px;

                ::v-deep .el-input__inner {
                    width: 197px;
                    height: 24px;
                    background: #fff;
                }
            }
        }

        ::v-deep .ux-table * {
            border: none;
        }

        ::v-deep .elx-table {
            border: 1px solid #00000026;
        }

        .footer {
            height: 43px;
            border-top: none;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 4px;
            background-color: #ededed;

            button {
                height: 24px;
            }
        }
    }
}
</style>
